/**
 * Object.seal(obj)
 * 不可添加新属性
 * 默认把configurable设置为false，不可修改属性描述符号，但是 writable 例外，可有true修改为false
 * 不可删除属性
 * 可修改属性值
 */

const obj = { name: 'jeff' };
console.log('before sealed: ', Object.getOwnPropertyDescriptors(obj));

Object.seal(obj);

obj.age = 23;

console.log('obj is sealed: ', Object.isSealed(obj));
console.log('after add new property obj: ', obj);
console.log('after sealed: ', Object.getOwnPropertyDescriptors(obj));

obj.name = 'feng';

console.log('after change value obj: ', obj);

// Object.defineProperty(obj, 'name', { enumerable: false }); // 不可defined
Object.defineProperty(obj, 'name', { writable: false }); // 但是writable可由true修改false
console.log(
  'after change writable to false: ',
  Object.getOwnPropertyDescriptors(obj)
);

delete obj.name;

console.log('after delete name obj: ', obj);
